package com.derbysoft.lowcostadapter.commons.model;

import com.derbysoft.common.domain.PersistenceSupport;
import com.derbysoft.lowcostadapter.commons.redis.utils.KeyValueHelper;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;

/**
 * Created by: jason
 * Date: 2012-10-25
 */
@Entity
public class Channel extends PersistenceSupport {

    public static final String PREFIX = "CHANNEL:";

    @Column(length = 20, unique = true)
    private String channelCode;

    @Column(length = 100)
    private String channelName;

    @Enumerated(EnumType.STRING)
    @Column(nullable = false)
    private AvailabilityProvider availabilityProvider;

    private Boolean normalMakeReservation;

    public Boolean getNormalMakeReservation() {
        return normalMakeReservation;
    }

    public void setNormalMakeReservation(Boolean normalMakeReservation) {
        this.normalMakeReservation = normalMakeReservation;
    }

    public String toKey() {
        return PREFIX + channelCode;
    }

    public String toValue() {
        return channelName + KeyValueHelper.SEPARATOR + availabilityProvider.getProvider() + KeyValueHelper.SEPARATOR + normalMakeReservation;
    }

    public AvailabilityProvider getAvailabilityProvider() {
        return availabilityProvider;
    }

    public void setAvailabilityProvider(AvailabilityProvider availabilityProvider) {
        this.availabilityProvider = availabilityProvider;
    }

    public String getChannelCode() {
        return channelCode;
    }

    public void setChannelCode(String channelCode) {
        this.channelCode = channelCode;
    }

    public String getChannelName() {
        return channelName;
    }

    public void setChannelName(String channelName) {
        this.channelName = channelName;
    }
}
